logo

Spring Boot Project Architecture

Author: Sai K

In this article, we will discuss how to create three-layered architecture in typical Spring boot MVC projects.

Spring Boot makes it easy to create stand-alone, production-grade Spring based Applications that you can "just run".

Three-tier (or three-layer) architecture is a widely accepted solution to organize the codebase. According to this architecture, the codebase is divided into three separate layers with distinctive responsibilities.


Learn Spring boot at https://www.javaguides.net/p/spring-boot-tutorial.html



Know how Spring MVC works atHow Spring MVC Works Internally


Three Tier (Three Layer) Architecture

Spring Boot follows a layered architecture in which each layer communicates with the layer directly below or above (hierarchical structure) it:

logo

Presentation layer: This is the user interface of the application that presents the application’s features and data to the user.

Business logic (or Application) layer: This layer contains the business logic that drives the application’s core functionalities. Like making decisions, calculations, evaluations, and processing the data passing between the other two layers.

Data access layer (or Data) layer: This layer is responsible for interacting with databases to save and retrieve application data.


Spring Boot Flow Architecture ( Example)

The below diagram shows the typical application flow of our Spring boot MVC web application with Thymeleaf:

logo
  1. Spring MVC controller receives an HTTP request from the client ( browser).
  2. Spring MVC controller process the request and sends that request to the service layer.
  3. Service Layer responsible to hold the business logic of the application.
  4. Repository layer responsible for interacting with databases to save and retrieve application data.
  5. Spring MVC controller return view ( JSP or Thymeleaf) to render on the browser.

Know how Spring MVC works atHow Spring MVC Works Internally


How to use Three-layer architecture in Spring Boot MVC web applications.

In a Spring boot MVC web application, the three layers of the architecture will manifest as follows:

logo

Consider below Spring MVC web application using Spring boot and Thymeleaf. We have created a three-layer architecture and each layer is mapped to the corresponding package.
For example:

logo

Conclusion

In this article, we have discussed how to create three-layered architecture in typical spring boot projects.

Three-tier (or three-layer) architecture is a widely accepted solution to organize the codebase. According to this architecture, the codebase is divided into three separate layers with distinctive responsibilities.



Learn Spring boot at https://www.javaguides.net/p/spring-boot-tutorial.html



Know how Spring MVC works atHow Spring MVC Works Internally


Related Spring and Spring Boot Tutorials/Guides: